<!--
Copyright (c) 2019-2026, Hossein Moein
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
  notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
  notice, this list of conditions and the following disclaimer in the
  documentation and/or other materials provided with the distribution.
* Neither the name of Hossein Moein and/or the DataFrame nor the
  names of its contributors may be used to endorse or promote products
  derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL Hossein Moein BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<!DOCTYPE html>
<html>
<body>

  <table align="center" border="1">

    <tr bgcolor="lightblue">
        <th>Signature</th> <th>Description</th> <th>Parameters</th>
    </tr>
    <tr bgcolor="lightgrey">
      <td bgcolor="maroon"> <font color="white">
        <PRE><B>
template&lt;typename ... Ts&gt;
DataFrame&lt;I&gt;
get_data(const std::vector&lt;const char *&gt; col_names) const;
        </B></PRE></font>
      </td>
      <td>
        This returns a DataFrame with index and col_names copied from the original DataFrame
      </td>
      <td>
        <B>Ts</b>: List types of col_names<BR>
        <B>col_names</b>: List of column names<BR>
      </td>
    </tr>

    <tr bgcolor="lightgrey">
      <td bgcolor="maroon"> <font color="white">
        <PRE><B>
template&lt;typename ... Ts&gt;
DataFrameView&lt;I&gt;
get_view(const std::vector&lt;const char *&gt; col_names);
        </B></PRE></font>
      </td>
      <td>
        It behaves like get_data(), but it returns a DataFrameView. A view is a DataFrame that is a reference to the original DataFrame. So if you modify anything in the view the original DataFrame will also be modified.<BR>
        <B>NOTE</B>: There are certain operations that you cannot do with a view. For example, you cannot add/delete columns, etc.<BR>
        <B>NOTE</B>: Views could not be const, becuase you can change original data through views.<BR>
      </td>
      <td>
        <B>Ts</b>: List types of col_names<BR>
        <B>col_names</b>: List of column names<BR>
      </td>
    </tr>

    <tr bgcolor="lightgrey">
      <td bgcolor="maroon"> <font color="white">
        <PRE><B>
template&lt;typename ... Ts&gt;
DataFrameConstView&lt;I&gt;
get_view(const std::vector&lt;const char *&gt; col_names) const;
        </B></PRE></font>
      </td>
      <td>
          Same as above view, but it returns a <I>const</I> view. You can not change data in const views. But if the data is changed in the original DataFrame or through another view, it is refelcted in the const view.       
      </td>
      <td>
        <B>Ts</b>: List types of col_names<BR>
        <B>col_names</b>: List of column names<BR>
      </td>
    </tr>

  </table>

<!-- HTML generated using hilite.me --><div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #008800; font-weight: bold">static</span> <span style="color: #333399; font-weight: bold">void</span> <span style="color: #0066BB; font-weight: bold">test_groupby_edge</span>()  {

    std<span style="color: #333333">::</span>cout <span style="color: #333333">&lt;&lt;</span> <span style="background-color: #fff0f0">&quot;</span><span style="color: #666666; font-weight: bold; background-color: #fff0f0">\n</span><span style="background-color: #fff0f0">Testing groupby( ) ...&quot;</span> <span style="color: #333333">&lt;&lt;</span> std<span style="color: #333333">::</span>endl;

    MyDataFrame                df;
    std<span style="color: #333333">::</span>vector<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">unsigned</span> <span style="color: #333399; font-weight: bold">long</span><span style="color: #333333">&gt;</span>  idxvec <span style="color: #333333">=</span>
        { <span style="color: #0000DD; font-weight: bold">1UL</span>, <span style="color: #0000DD; font-weight: bold">2UL</span>, <span style="color: #0000DD; font-weight: bold">3UL</span>, <span style="color: #0000DD; font-weight: bold">10UL</span>, <span style="color: #0000DD; font-weight: bold">5UL</span>, <span style="color: #0000DD; font-weight: bold">7UL</span>, <span style="color: #0000DD; font-weight: bold">8UL</span>, <span style="color: #0000DD; font-weight: bold">12UL</span>, <span style="color: #0000DD; font-weight: bold">9UL</span>, <span style="color: #0000DD; font-weight: bold">12UL</span>, <span style="color: #0000DD; font-weight: bold">10UL</span>, <span style="color: #0000DD; font-weight: bold">13UL</span>,
          <span style="color: #0000DD; font-weight: bold">10UL</span>, <span style="color: #0000DD; font-weight: bold">15UL</span>, <span style="color: #0000DD; font-weight: bold">14UL</span> };
    std<span style="color: #333333">::</span>vector<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>         dblvec <span style="color: #333333">=</span>
        { <span style="color: #6600EE; font-weight: bold">0.0</span>, <span style="color: #6600EE; font-weight: bold">15.0</span>, <span style="color: #333333">-</span><span style="color: #6600EE; font-weight: bold">14.0</span>, <span style="color: #6600EE; font-weight: bold">2.0</span>, <span style="color: #6600EE; font-weight: bold">1.0</span>, <span style="color: #6600EE; font-weight: bold">12.0</span>, <span style="color: #6600EE; font-weight: bold">11.0</span>, <span style="color: #6600EE; font-weight: bold">8.0</span>, <span style="color: #6600EE; font-weight: bold">7.0</span>, <span style="color: #6600EE; font-weight: bold">6.0</span>, <span style="color: #6600EE; font-weight: bold">5.0</span>, <span style="color: #6600EE; font-weight: bold">4.0</span>,
          <span style="color: #6600EE; font-weight: bold">3.0</span>, <span style="color: #6600EE; font-weight: bold">9.0</span>, <span style="color: #6600EE; font-weight: bold">10.0</span>};
    std<span style="color: #333333">::</span>vector<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>         dblvec2 <span style="color: #333333">=</span>
        { <span style="color: #6600EE; font-weight: bold">100.0</span>, <span style="color: #6600EE; font-weight: bold">101.0</span>, <span style="color: #6600EE; font-weight: bold">102.0</span>, <span style="color: #6600EE; font-weight: bold">103.0</span>, <span style="color: #6600EE; font-weight: bold">104.0</span>, <span style="color: #6600EE; font-weight: bold">105.0</span>, <span style="color: #6600EE; font-weight: bold">106.55</span>, <span style="color: #6600EE; font-weight: bold">107.34</span>, <span style="color: #6600EE; font-weight: bold">1.8</span>,
          <span style="color: #6600EE; font-weight: bold">111.0</span>, <span style="color: #6600EE; font-weight: bold">112.0</span>, <span style="color: #6600EE; font-weight: bold">113.0</span>, <span style="color: #6600EE; font-weight: bold">114.0</span>, <span style="color: #6600EE; font-weight: bold">115.0</span>, <span style="color: #6600EE; font-weight: bold">116.0</span>};
    std<span style="color: #333333">::</span>vector<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">int</span><span style="color: #333333">&gt;</span>            intvec <span style="color: #333333">=</span> { <span style="color: #0000DD; font-weight: bold">1</span>, <span style="color: #0000DD; font-weight: bold">2</span>, <span style="color: #0000DD; font-weight: bold">3</span>, <span style="color: #0000DD; font-weight: bold">4</span>, <span style="color: #0000DD; font-weight: bold">5</span>, <span style="color: #0000DD; font-weight: bold">8</span>, <span style="color: #0000DD; font-weight: bold">6</span>, <span style="color: #0000DD; font-weight: bold">7</span>, <span style="color: #0000DD; font-weight: bold">11</span>, <span style="color: #0000DD; font-weight: bold">14</span>, <span style="color: #0000DD; font-weight: bold">9</span> };
    std<span style="color: #333333">::</span>vector<span style="color: #333333">&lt;</span>std<span style="color: #333333">::</span>string<span style="color: #333333">&gt;</span>    strvec <span style="color: #333333">=</span>
        { <span style="background-color: #fff0f0">&quot;zz&quot;</span>, <span style="background-color: #fff0f0">&quot;bb&quot;</span>, <span style="background-color: #fff0f0">&quot;cc&quot;</span>, <span style="background-color: #fff0f0">&quot;ww&quot;</span>, <span style="background-color: #fff0f0">&quot;ee&quot;</span>, <span style="background-color: #fff0f0">&quot;ff&quot;</span>, <span style="background-color: #fff0f0">&quot;gg&quot;</span>, <span style="background-color: #fff0f0">&quot;hh&quot;</span>, <span style="background-color: #fff0f0">&quot;ii&quot;</span>, <span style="background-color: #fff0f0">&quot;jj&quot;</span>, <span style="background-color: #fff0f0">&quot;kk&quot;</span>,
          <span style="background-color: #fff0f0">&quot;ll&quot;</span>, <span style="background-color: #fff0f0">&quot;mm&quot;</span>, <span style="background-color: #fff0f0">&quot;nn&quot;</span>, <span style="background-color: #fff0f0">&quot;oo&quot;</span> };
    dblvec2.resize(<span style="color: #0000DD; font-weight: bold">1</span>);
    dblvec.resize(<span style="color: #0000DD; font-weight: bold">1</span>);
    strvec.resize(<span style="color: #0000DD; font-weight: bold">1</span>);
    intvec.resize(<span style="color: #0000DD; font-weight: bold">1</span>);
    idxvec.resize(<span style="color: #0000DD; font-weight: bold">1</span>); <span style="color: #888888">// make this greater then one to fix coredump with hack</span>
    df.load_data(std<span style="color: #333333">::</span>move(idxvec),
                 std<span style="color: #333333">::</span>make_pair(<span style="background-color: #fff0f0">&quot;dbl_col&quot;</span>, dblvec),
                 std<span style="color: #333333">::</span>make_pair(<span style="background-color: #fff0f0">&quot;dbl_col_2&quot;</span>, dblvec2),
                 std<span style="color: #333333">::</span>make_pair(<span style="background-color: #fff0f0">&quot;str_col&quot;</span>, strvec));
    df.load_column(<span style="background-color: #fff0f0">&quot;int_col&quot;</span>, std<span style="color: #333333">::</span>move(intvec),
                   nan_policy<span style="color: #333333">::</span>dont_pad_with_nans);

    FactorizeVisitor<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>    fact([] (<span style="color: #008800; font-weight: bold">const</span> <span style="color: #333399; font-weight: bold">double</span> <span style="color: #333333">&amp;</span>f) <span style="color: #333333">-&gt;</span> <span style="color: #333399; font-weight: bold">bool</span> {
                                         <span style="color: #008800; font-weight: bold">return</span> (f <span style="color: #333333">&gt;</span> <span style="color: #6600EE; font-weight: bold">11106.0</span> <span style="color: #333333">&amp;&amp;</span> f <span style="color: #333333">&lt;</span> <span style="color: #6600EE; font-weight: bold">114.0</span>);
                                     });
    df.load_column(<span style="background-color: #fff0f0">&quot;bool_col&quot;</span>,
                   df.single_act_visit<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>(<span style="background-color: #fff0f0">&quot;dbl_col_2&quot;</span>, fact).get_result());

    df.write<span style="color: #333333">&lt;</span>std<span style="color: #333333">::</span>ostream, std<span style="color: #333333">::</span>string, <span style="color: #333399; font-weight: bold">double</span>, <span style="color: #333399; font-weight: bold">int</span>, <span style="color: #333399; font-weight: bold">bool</span><span style="color: #333333">&gt;</span>
        (std<span style="color: #333333">::</span>cout, io_format<span style="color: #333333">::</span>csv2);

    <span style="color: #008800; font-weight: bold">auto</span> bool_df <span style="color: #333333">=</span> df.groupby1<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">bool</span><span style="color: #333333">&gt;</span>(
        <span style="background-color: #fff0f0">&quot;bool_col&quot;</span>,
        LastVisitor<span style="color: #333333">&lt;</span>MyDataFrame<span style="color: #333333">::</span>IndexType, MyDataFrame<span style="color: #333333">::</span>IndexType<span style="color: #333333">&gt;</span>(),
        std<span style="color: #333333">::</span>make_tuple(<span style="background-color: #fff0f0">&quot;dbl_col_2&quot;</span>, <span style="background-color: #fff0f0">&quot;sum_dbl2&quot;</span>, SumVisitor<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>()),
        std<span style="color: #333333">::</span>make_tuple(<span style="background-color: #fff0f0">&quot;dbl_col_2&quot;</span>, <span style="background-color: #fff0f0">&quot;cnt_dbl2&quot;</span>, CountVisitor<span style="color: #333333">&lt;</span><span style="color: #333399; font-weight: bold">double</span><span style="color: #333333">&gt;</span>()));
    bool_df.write<span style="color: #333333">&lt;</span>std<span style="color: #333333">::</span>ostream, <span style="color: #333399; font-weight: bold">double</span>, std<span style="color: #333333">::</span><span style="color: #333399; font-weight: bold">size_t</span>, <span style="color: #333399; font-weight: bold">bool</span><span style="color: #333333">&gt;</span>
        (std<span style="color: #333333">::</span>cout, io_format<span style="color: #333333">::</span>csv2);
}
</pre></div>


  <img src="https://github.com/hosseinmoein/DataFrame/blob/master/docs/LionLookingUp.jpg?raw=true" alt="C++ DataFrame"
       width="200" height="150" style="float:right"/>

</body>
</html>

<!--
Local Variables:
mode:HTML
tab-width:4
c-basic-offset:4
End:
-->
